package top.yihoxu.yoj.judge.strategy;

import org.springframework.stereotype.Service;
import top.yihoxu.yoj.judge.codesandbox.model.JudgeInfo;
import top.yihoxu.yoj.model.entity.QuestionSubmit;

/**
 * @Author dth
 * @Date 2024/5/3 23:40
 * @PackageName:top.yihoxu.yoj.judge.strategy
 * @ClassName: JudgeManager
 * @Description: 判题管理
 * @Version 1.0
 */
@Service
public class JudgeManager {

   public JudgeInfo doJudge(JudgeContext judgeContext) {
        QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
        String language = questionSubmit.getLanguage();
        JudgeStrategy judgeStrategy = new DefaultJudgeStrategy();
        if ("java".equals(language)) {
            judgeStrategy = new JavaLanguageJudgeStrategy();
        }
        return judgeStrategy.doJudge(judgeContext);
    }
}
